****Military Attitudes Survey
****Data collected by Qualtrics 1/17/2020 - 1/29/2020

*Use data file: QualtricsRepData.dta

*********************************
*Independent Variables***********
*********************************
*Note: tables for these recoded variables are the basis for the corresponding sample demographic information Appendix Table 1 and sample information in the Supplemental Materials


*********************************************
*Terrorism Stuff
*********************************************
tab TerrorGroup
gen terror=.
replace terror=0 if TerrorGroup=="TerrControl"
replace terror=1 if TerrorGroup=="TerrIF"
replace terror=2 if TerrorGroup=="TerrWN"
tab terror
label define terror 0 "Control" 1 "Islamic Fundamentalist" 2 "White Nationalist"
label values terror terror
tab terror



*Q6 Are you now serving, have previously served, or have never served in the U.S. armed forces? Select all that apply.
*Now serving on active duty in the U.S. Air Force, Army, Coast Guard, Marine Corps, or Navy  (1) 
*Now serving in the National Guard or Reserve  (2) 
*Previously served on active duty in the U.S. Air Force, Army, Coast Guard, Marine Corps, or Navy  (3) 
*Previously served in the National Guard or Reserve  (4) 
*[dropped] I have never served in the U.S. military  (5) 
tab Q6

gen active=.
replace active=1 if Q6=="1"
replace active=1 if Q6=="1,2"
replace active=1 if Q6=="1,2,3"
replace active=1 if Q6=="1,2,3,4"
replace active=1 if Q6=="1,2,4"
replace active=1 if Q6=="1,3"
replace active=1 if Q6=="1,3,4"
replace active=1 if Q6=="1,4"
replace active=1 if Q6=="2"
replace active=1 if Q6=="2,3"
replace active=1 if Q6=="2,4"
replace active=0 if Q6=="3"
replace active=0 if Q6=="3,4"
replace active=0 if Q6=="4"
replace active=. if Q6=="5"
tab active


***Partisanship

*Q17 Generally speaking, do you think of yourself as a Republican, Democrat, or Independent?
*Republican  (1) 
*Democrat  (2) 
*Independent  (3) 
tab Q17

*Q18 Would you call yourself a strong Democrat or not a very strong Democrat?
*Strong Democrat  (1) 
*Not very strong Democrat  (2) 
tab Q18

*Q19 Would you call yourself a strong Republican or not a very strong Republican?
*Strong Republican  (1) 
*Not very strong Republican  (2) 
tab Q19

*Q20 Do you think of yourself as closer to the Republican Party or the Democratic Party?
*Closer to the Republican Party  (1) 
*Closer to the Democratic Party  (3) 
tab Q20

*Partisanship  scaled
gen party=.
replace party=1 if Q18==1
replace party=2 if Q18==2
replace party=3 if Q20==3
replace party=4 if Q20==1
replace party=5 if Q19==2
replace party=6 if Q19==1
tab party

*Partisanship, dichotomous
gen party2=.
replace party2=0 if party==1
replace party2=0 if party==2
replace party2=0 if party==3
replace party2=1 if party==4
replace party2=1 if party==5
replace party2=1 if party==6
tab party2
label define party2 0 "Democrat" 1 "Republican"
label values party2 party2
tab party2


*Ideology. 1 extremely liberal to 7 extremely conservative
tab Q5
gen ideo=Q5
tab ideo

*Q4 What is your gender?
*Male  (1) 
*Female  (2) 
*Other  (3) 
tab Q4
gen gender3=.
replace gender3=0 if Q4==1
replace gender3=1 if Q4==2
replace gender3=2 if Q4==3
tab gender3
label define gender3 0 "Male" 1 "Female" 2 "Other"
label values gender3 gender3
tab gender3

gen gender2=gender3
replace gender2=. if gender3==2
label define gender2 0 "Male" 1 "Female"
label values gender2 gender2
tab gender2

*Age Q84 What is your age?
tab Q84
gen newage=Q84
replace newage=. if Q84==99
tab newage
mean newage

*Education Q83 What is the highest level of education you have completed?
tab Q83
gen edu=Q83
tabstat edu, stats (p50 mean n)
tab edu

*Income Q85 What is your estimate of your annual household income (before taxes)?
tab Q85
gen income=Q85
tabstat income, stats (p50 mean n)


*Race
*Q2 Are you Spanish, Hispanic, Latino, or none of these?
*Yes  (1) 
*None of these  (0) 
*Q3 Choose one or more races that you consider yourself to be. Check all that apply. 
*White  (1) 
*Black or African American  (2) 
*American Indian or Alaskan Native  (3) 
*Asian  (4) 
*Native Hawaiian or Pacific Islander  (5) 
*Other (please specify)  (6) 
tab Q2
tab Q3

gen race3=.
replace race3=0 if Q2==0 & Q3=="1"
replace race3=1 if Q2==0 & Q3=="2"
replace race3=2 if Q2==1 & Q3=="1"
replace race3=2 if Q2==1 & Q3=="2"
replace race3=2 if Q3=="1,2"
replace race3=2 if Q3=="1,2,3"
replace race3=2 if Q3=="1,2,3,4,5"
replace race3=2 if Q3=="1,2,3,5"
replace race3=2 if Q3=="1,2,5"
replace race3=2 if Q3=="1,3"
replace race3=2 if Q3=="1,4"
replace race3=2 if Q3=="1,4,5"
replace race3=2 if Q3=="1,5"
replace race3=2 if Q3=="2,3"
replace race3=2 if Q3=="2,4"
replace race3=2 if Q3=="2,5"
replace race3=2 if Q3=="3"
replace race3=2 if Q3=="3,6"
replace race3=2 if Q3=="4"
replace race3=2 if Q3=="5"
replace race3=2 if Q3=="6"
tab race3
label define race3 0 "Non-Hispanic White" 1 "Non-Hispanic Black" 2 "Other"
label values race3 race3
tab race3



*Q13 What is your rank? If you are no longer serving in the military, mark your rank when you left the service.
*Enlisted (E-1 thru E-9)  (1) 
*Warrant Officer (W-1 thru W-5)  (2) 
*Officer (O-1 thru O-10)  (3) 
tab Q13
gen rank=Q13
tab rank
label define rank 1 "Enlisted" 2 "Warrant Officer" 3 "Officer"
label values rank rank
tab rank

gen rank2=.
replace rank2=0 if rank==1
replace rank2=1 if rank==2
replace rank2=1 if rank==3
tab rank2


*** Separate experiment in this survey. Will control for this.
tab AFGroup
gen affgroup=.
replace affgroup=0 if AFGroup=="Control"
replace affgroup=1 if AFGroup=="IDTreat"
replace affgroup=2 if AFGroup=="NormTreat"
tab affgroup
label define affgroup 0 "Control" 1 "Identity Treatment" 2 "Norm Treatment"
label values affgroup affgroup
tab affgroup



*********************************************
*Civil Liberty Dependent Variables
*********************************************


*Q57 Should people suspected of terrorist involvement be banned from making public speeches?
*Q63 Should Islamic Fundamentalists suspected of terrorist involvement be banned from making public speeches?
*Q69 Should White Nationalists suspected of terrorist involvement be banned from making public speeches?
*Yes = 1
*No = 0

gen speech=.
replace speech=1 if Q57==1
replace speech=1 if Q63==1
replace speech=1 if Q69==1
replace speech=0 if Q57==0
replace speech=0 if Q63==0
replace speech=0 if Q69==0
tab speech
label define speech 0 "No" 1 "Yes"
label values speech speech
tab speech

**Info for Table 3
*Dem
tab speech terror if(party2==0), col
prtest speech if(terror==0 & party2==0 | terror==1 & party2==0), by(terror)
prtest speech if(terror==0 & party2==0 | terror==2 & party2==0), by(terror)
*Rep
tab speech terror if(party2==1), col
prtest speech if(terror==0 & party2==1 | terror==1 & party2==1), by(terror)
prtest speech if(terror==0 & party2==1 | terror==2 & party2==1), by(terror)
*Full Model for Supplementals
logit speech i.terror i.party2 i.gender2 i.race3 edu newage income i.affgroup i.terror##i.party2, robust
*outreg2 using ModelsDi.doc, replace ctitle(Ban Speech) label 
margins, dydx(i.terror) at(party2=(0 1)) vsquish
marginsplot, scheme(s1mono)  xlab(-.25 " " 0 "Democrat" 1 "Republican" 1.25 " ", ) title("Effect on Probability of Support for Banning Speech (Military)") yline(0,lpattern(dot))  xtitle("Partisanship", margin(medium)) ytitle("Effect on Probability of Support", margin(medium)) plot(,label("Islamic Fundamentalist" "White Nationalist"))
*graph export SpeechParty.pdf, replace
*Predicted Probabilities for Table 3
margins i.terror, at(party2=(0 1)) vsquish


*Q55 If a person is suspected of being a terrorist, should the government be allowed to monitor their phone calls without obtaining a warrant?
*Q61 If a person is suspected of being an Islamic Fundamentalist terrorist, should the government be allowed to monitor their phone calls without obtaining a warrant?
*Q67 If a person is suspected of being a White Nationalist terrorist, should the government be allowed to monitor their phone calls without obtaining a warrant?
*Yes = 1
*No = 0
tab Q55
tab Q61
tab Q67

gen monitor=.
replace monitor=1 if Q55==1
replace monitor=1 if Q61==1
replace monitor=1 if Q67==1
replace monitor=0 if Q55==0
replace monitor=0 if Q61==0
replace monitor=0 if Q67==0
tab monitor
label define monitor 0 "No" 1 "Yes"
label values monitor monitor
tab monitor

**Info for Table 3
*Dem
tab monitor terror if(party2==0), col
prtest monitor if(terror==0 & party2==0 | terror==1 & party2==0), by(terror)
prtest monitor if(terror==0 & party2==0 | terror==2 & party2==0), by(terror)
*Rep
tab monitor terror if(party2==1), col
prtest monitor if(terror==0 & party2==1 | terror==1 & party2==1), by(terror)
prtest monitor if(terror==0 & party2==1 | terror==2 & party2==1), by(terror)
*Full Model for Supplementals
logit monitor i.terror i.party2 i.gender2 i.race3 edu newage income i.affgroup i.terror##i.party2, robust
*outreg2 using ModelsDi.doc, append ctitle(Monitor) label 
margins, dydx(i.terror) at(party2=(0 1)) vsquish
marginsplot, scheme(s1mono)  xlab(-.25 " " 0 "Democrat" 1 "Republican" 1.25 " ", ) title("Effect on Probability of Support for Monitoring Phone (Military)") yline(0,lpattern(dot))  xtitle("Partisanship", margin(medium)) ytitle("Effect on Probability of Support", margin(medium)) plot(,label("Islamic Fundamentalist" "White Nationalist"))
*graph export MonitorParty.pdf, replace
*Predicted Probabilities for Table 3
margins i.terror, at(party2=(0 1)) vsquish

*Q56 Should the government shut down social media accounts belonging to someone suspected of being a terrorist?
*Q62 Should the government shut down social media accounts belonging to someone suspected of being an Islamic Fundamentalist terrorist?
*Q68 Should the government shut down social media accounts belonging to someone suspected of being a White Nationalist terrorist?
*Yes = 1
*No = 2

gen socialmed=.
replace socialmed=1 if Q56==1
replace socialmed=1 if Q62==1
replace socialmed=1 if Q68==1
replace socialmed=0 if Q56==2
replace socialmed=0 if Q62==2
replace socialmed=0 if Q68==2
tab socialmed
tab socialmed
label define socialmed 0 "No" 1 "Yes"
label values socialmed socialmed
tab socialmed

**Info for Table 3
*Dem
tab socialmed terror if(party2==0), col
prtest socialmed if(terror==0 & party2==0 | terror==1 & party2==0), by(terror)
prtest socialmed if(terror==0 & party2==0 | terror==2 & party2==0), by(terror)
*Rep
tab socialmed terror if(party2==1), col
prtest socialmed if(terror==0 & party2==1 | terror==1 & party2==1), by(terror)
prtest socialmed if(terror==0 & party2==1 | terror==2 & party2==1), by(terror)
*Full Model for Supplementals
logit socialmed i.terror i.party2 i.gender2 i.race3 edu newage income i.affgroup i.terror##i.party2, robust
*outreg2 using ModelsDi.doc, append ctitle(Social Media) label 
margins, dydx(i.terror) at(party2=(0 1)) vsquish
marginsplot, scheme(s1mono)  xlab(-.25 " " 0 "Democrat" 1 "Republican" 1.25 " ", ) title("Effect on Prob. of Support for Shutting Down Social Media (Military)") yline(0,lpattern(dot))  xtitle("Partisanship", margin(medium)) ytitle("Effect on Probability of Support", margin(medium)) plot(,label("Islamic Fundamentalist" "White Nationalist"))
*graph export MediaParty.pdf, replace
*Predicted Probabilities for Table 3
margins i.terror, at(party2=(0 1)) vsquish


*Q58 Should the government be allowed to hold a person suspected of being a terrorist for an unlimited amount of time?
*Q64 Should the government be allowed to hold an Islamic Fundamentalist suspected of plotting a terror attack for an unlimited amount of time?
*Q70 Should the government be allowed to hold a White Nationalist suspected of plotting a terror attack for an unlimited amount of time?
*Yes = 1
*No = 0

gen hold=.
replace hold=1 if Q58==1
replace hold=1 if Q64==1
replace hold=1 if Q70==1
replace hold=0 if Q58==0
replace hold=0 if Q64==0
replace hold=0 if Q70==0
tab hold
label define hold 0 "No" 1 "Yes"
label values hold hold
tab hold

**Info for Table 3
*Dem
tab hold terror if(party2==0), col
prtest hold if(terror==0 & party2==0 | terror==1 & party2==0), by(terror)
prtest hold if(terror==0 & party2==0 | terror==2 & party2==0), by(terror)
*Rep
tab hold terror if(party2==1), col
prtest hold if(terror==0 & party2==1 | terror==1 & party2==1), by(terror)
prtest hold if(terror==0 & party2==1 | terror==2 & party2==1), by(terror)
*Full Model for Supplementals
logit hold i.terror i.party2 i.gender2 i.race3 edu newage income i.affgroup i.terror##i.party2, robust
*outreg2 using ModelsDi.doc, append ctitle(Hold) label 
margins, dydx(i.terror) at(party2=(0 1)) vsquish
marginsplot, scheme(s1mono)  xlab(-.25 " " 0 "Democrat" 1 "Republican" 1.25 " ", ) title("Effect on Prob. of Support for Holding Indefinitely (Military)") yline(0,lpattern(dot))  xtitle("Partisanship", margin(medium)) ytitle("Effect on Probability of Support", margin(medium)) plot(,label("Islamic Fundamentalist" "White Nationalist"))
*graph export HoldParty.pdf, replace
*Predicted Probabilities for Table 3
margins i.terror, at(party2=(0 1)) vsquish


***** 4 item index
tab speech
tab monitor
tab socialmed
tab hold

gen addindex= speech + monitor + socialmed + hold
tab addindex


gen avgindex= addindex/4
tab avgindex

**Info for Table 3
*Dem
tabstat avgindex if(party2==0), by(terror) stats(mean sem n)
ttest avgindex if(terror==0 & party2==0 | terror==1 & party2==0), by(terror)
ttest avgindex  if(terror==0 & party2==0 | terror==2 & party2==0), by(terror)
*Rep
tabstat avgindex if(party2==1), by(terror) stats(mean sem n)
ttest avgindex if(terror==0 & party2==1 | terror==1 & party2==1), by(terror)
ttest avgindex  if(terror==0 & party2==1 | terror==2 & party2==1), by(terror)
*Full Model for Table 2
regress avgindex i.terror i.party2 i.gender2 i.race3 edu newage income i.affgroup i.terror##i.party2, robust
*outreg2 using ModelsDi.doc, append ctitle(Index) label 
*Figure 2
margins, dydx(i.terror) at(party2=(0 1)) vsquish
marginsplot, scheme(s1mono)  xlab(-.25 " " 0 "Democrat" 1 "Republican" 1.25 " ", ) title("Effect on Support for Restrictions (Index, Military)") yline(0,lpattern(dot))  xtitle("Partisanship", margin(medium)) ytitle("Effect on Support for Restrictions", margin(medium)) plot(,label("Islamic Fundamentalist" "White Nationalist"))
*graph export AverageIndex.pdf, replace

margins i.terror, at(party2=(0 1)) vsquish




**************************************
*Analyses for Supplemental Materials**
**************************************

*Models with no controls (still interacting party and treatment)
logit speech i.terror i.party2 i.terror##i.party2, robust
*outreg2 using NoControlModels.doc, replace ctitle(Ban Speech) label
logit monitor i.terror i.party2  i.terror##i.party2
*outreg2 using NoControlModels.doc, append ctitle(Monitor) label
logit socialmed i.terror i.party2  i.terror##i.party2
*outreg2 using NoControlModels.doc, append ctitle(Social Media) label
logit hold i.terror i.party2  i.terror##i.party2
*outreg2 using NoControlModels.doc, append ctitle(Hold) label
regress avgindex i.terror i.party2  i.terror##i.party2, robust
*outreg2 using NoControlModels.doc, append ctitle(Index) label

*Models with no controls or interactions for party; just average treatment effects
logit speech i.terror, robust
*outreg2 using ATEModels.doc, replace ctitle(Ban Speech) label
logit monitor i.terror, robust
*outreg2 using ATEModels.doc, append ctitle(Monitor) label 
logit socialmed i.terror, robust
*outreg2 using ATEModels.doc, append ctitle(Social Media) label 
logit hold i.terror, robust
*outreg2 using ATEModels.doc, append ctitle(Hold) label
regress avgindex i.terror, robust
*outreg2 using ATEModels.doc, append ctitle(Index) label



***Models to be corrected for multiple group comparisons
regress avgindex i.terror i.party2  i.terror##i.party2, robust pformat(%5.4f) 
regress avgindex i.terror i.party2 i.gender2 i.race3 edu newage income i.affgroup i.terror##i.party2, robust pformat(%5.4f) 

